/*
 * @Author: your name
 * @Date: 2021-10-17 19:57:10
 * @LastEditTime: 2021-10-17 20:38:08
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\动态规划\背包\完全背包\P1679 神奇的四次方数\main.cpp
 */
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int f[100010];

int main(){
    int m;
    cin >> m;
    int m1 = ceil(sqrt(sqrt(m)));
    memset(f,0xf,sizeof(f));
    f[0] = 0; //让 j=v 时使得 加入该数字 f[j] = 1
    for(int i=1; i<=m1; i++){
        int v = i*i*i*i;
        for(int j=v; j<=m; j++){
           f [j] = min(f[j],f[j-v]+1);
        }
    }
    cout << f[m] << endl;
    return 0;
}